package com.zero2oneblog.vo;

import static com.zero2oneblog.constant.StatusCodeEnum.SUCCESS;

public class ResponseVO<T> {
    private int status;

    public ResponseVO() {
    }

    public ResponseVO(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    private String message;
    private T data;


    public static <T> ResponseVO<T> responseVO(int status, String message, T data){
        ResponseVO<T> response = new ResponseVO<>();
        response.setStatus(status);
        response.setMessage(message);
        response.setData(data);
        return response;
    }

    public static <T> ResponseVO<T> ok(T data){
        return responseVO(SUCCESS.getCode(),SUCCESS.getDesc(),data);
    }
}
